package com.coder.books.thinkinjava.io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import static com.coder.books.thinkinjava.io.DirList.IO_PATH;

/**
 *
 * @author yuhushuan
 * @date 2020/8/24 22:32
 */
public class BufferedInputFile {
    public static String read(String filename) throws IOException {
        BufferedReader in =
                new BufferedReader(new FileReader(filename));

        String s;
        StringBuilder sb = new StringBuilder();
        while ((s = in.readLine()) != null)
            sb.append(s).append("\n");
        in.close();
        return sb.toString();
    }

    public static void main(String[] args) throws IOException {
        System.out.println(read(IO_PATH + "BufferedInputFile.java"));
    }
}
